use super::*;
enum Mode {
Strip,
Bus,
}
impl std::fmt::Display for Mode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Mode::Strip => f.write_str(STRIP),
Mode::Bus => f.write_str(BUS),
}
}
}
pub struct EqChannelParameter<'a> {
remote: &'a VoicemeeterRemote,
mode: Mode,
index: ZIndex,
channel: usize,
}
impl<'a> EqChannelParameter<'a> {
pub(crate) fn new_bus(remote: &'a VoicemeeterRemote, index: ZIndex, channel: usize) -> Self {
Self {
remote,
mode: Mode::Bus,
index,
channel,
}
}
pub(crate) fn new_strip(remote: &'a VoicemeeterRemote, index: ZIndex, channel: usize) -> Self {
Self {
remote,
mode: Mode::Strip,
index,
channel,
}
}
pub(crate) fn name(&self) -> impl std::fmt::Display + '_ {
struct N<'s>(&'s Mode, &'s ZIndex, &'s usize);
impl std::fmt::Display for N<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}[{}].EQ.channel[{}]", self.0, self.1, self.2)
}
}
N(&self.mode, &self.index, &self.channel)
}
pub fn param(&self, cell: usize, dot: impl ToString) -> Cow<'static, ParameterNameRef> {
Cow::Owned(format!("{}.cell[{}].{}", self.name(), cell, dot.to_string()).into())
}
pub fn on(&self, cell: usize) -> BoolParameter {
BoolParameter::new(self.param(cell, "on"), self.remote)
}
pub fn type_(&self, cell: usize) -> IntParameter {
IntParameter::new(self.param(cell, "type"), self.remote, 0..=6)
}
pub fn f(&self, cell: usize) -> FloatParameter {
FloatParameter::new(self.param(cell, "f"), self.remote, 20.0..=20_000.0)
}
pub fn gain(&self, cell: usize) -> FloatParameter {
FloatParameter::new(self.param(cell, "gain"), self.remote, -36.0..=18.0)
}
pub fn q(&self, cell: usize) -> IntParameter {
IntParameter::new(self.param(cell, "q"), self.remote, 1..=100)
}
}